﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Frogger
{
    class MoveableEntity : Entity
    {
        //Speed
        protected Vector2 __speed;
        protected Vector2 __originalSpeed;

        public override Vector2 direction
        {
            get
            {
                return this.__speed;
            }
            protected set
            {
                this.__speed = value;
            }
        }

        //Constructors
        public MoveableEntity(Texture2D textureImage, Vector2 position, Point frameSize,
            int collisionOffset, Point currentFrame, Point sheetSize, Vector2 speed,
            int millisecondsPerFrame, string name, int scoreValue):base(textureImage, position, frameSize, collisionOffset, currentFrame,
            sheetSize, millisecondsPerFrame, name, scoreValue)
        { 
            this.__speed = speed;
            this.__originalSpeed = speed;
        }

        public MoveableEntity(Texture2D textureImage, Vector2 position, Point frameSize,
            int collisionOffset, Point currentFrame, Point sheetSize, Vector2 speed,
            string name, int scoreValue)
            : base(textureImage, position, frameSize, collisionOffset, currentFrame,
            sheetSize, name, scoreValue)
        {
            this.__speed = speed;
            this.__originalSpeed = speed;

        }

         public MoveableEntity(Texture2D textureImage, Vector2 position, Point frameSize,
            int collisionOffset, Point currentFrame, Point sheetSize, Vector2 speed,
            string name, int scoreValue, float scale)
            : base(textureImage, position, frameSize, collisionOffset, currentFrame,
            sheetSize, name, scoreValue, scale)
        {
            this.__speed = speed;
            this.__originalSpeed = speed;
  
        }

         public void ModifySpeed(float modifier)
         {
             this.__speed *= modifier;
         }

         public void ResetSpeed()
         {
             this.__speed = this.__originalSpeed;
         }

        public Vector2 GetSpeed()
        {
            return this.__speed;
        }

        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(this.__textureImage,
                            this.__position,
                            new Rectangle(this.__frameSize.X * this.__currentFrame.X,
                                this.__frameSize.Y * this.__currentFrame.Y,
                                this.__frameSize.X, this.__frameSize.Y),
                                Color.White, 0, Vector2.Zero,
                                this.__scale, SpriteEffects.None, 0);
        }

        public override Rectangle collisionRect
        {
            get
            {
                return new Rectangle(
                    (int)(__position.X + (__collisionOffset * __scale)),
                    (int)(__position.Y + (__collisionOffset * __scale)),
                    (int)((__frameSize.Y - (__collisionOffset)) * __scale),
                    (int)((__frameSize.X - (__collisionOffset)) * __scale)
                    );
            }
        }
    }
}
